package yzrilyzr.simplesynth.app;
import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;

import yzrilyzr.util.AndroidUtil;

public class PlayerService extends Service{
	Runnable updateRunnable;
	Handler handler=new Handler();
	@Override
	public void onCreate(){
		super.onCreate();
		updateRunnable=new Runnable(){
			@Override
			public void run(){
				AppInstance.next();
				if(updateRunnable!=null) handler.postDelayed(this,100);
			}
		};
		updateRunnable.run();
	}
	@Override
	public int onStartCommand(Intent intent,int flags,int startId){
		Notification.Builder bd=new Notification.Builder(this);
		AndroidUtil.createChannel(bd,null,null,"ch1",Notification.PRIORITY_DEFAULT,null);
		startForeground(START_STICKY,bd.build());
		return START_STICKY;
	}
	@Override
	public void onDestroy(){
		super.onDestroy();
		updateRunnable=null;
	}
	@Override
	public IBinder onBind(Intent p1){
		// TODO: Implement this method
		return null;
	}
}
